import { createStore, applyMiddleware, compose} from 'redux'  // 引入createStore方法
import reducer from './reducer'
// import thunk from 'redux-thunk' 调用中间建 01
import createSagaMiddleware from 'redux-saga'   //引入saga 02
import mySagas from './sagas' 
const sagaMiddleware = createSagaMiddleware();   //创建saga中间件


const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ?
  window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({}) : compose

// const enhancer = composeEnhancers(applyMiddleware(thunk)) 01
const enhancer = composeEnhancers(applyMiddleware(sagaMiddleware))

const store = createStore(reducer,enhancer) // 创建数据存储仓库

sagaMiddleware.run(mySagas)


export default store                 //暴露出去